package com.ty.init.uitl;

import lombok.Data;

import java.io.Serializable;

/**
 * @author ty
 */
@Data
public class JsonResult<T> implements Serializable {
    private Integer code;
    private String message;
    private T data;
    private Integer count;

    public JsonResult(){

    }
    public JsonResult(Integer state){
        this.code = state;
    }
    public JsonResult(Integer state, T data){
        this.code = state;
        this.data = data;
    }
    public JsonResult(Throwable e){
        this.message = e.getMessage();
    }

    public JsonResult(Integer state, String message, T data) {
        this.code = state;
        this.message = message;
        this.data = data;
    }

    public JsonResult(Integer code, Integer count, T data) {
        this.code = code;
        this.data = data;
        this.count = count;
    }

    public static JsonResult<Object> fail(String message){
        return new JsonResult(-1,message,null);
    }
}
